Skip to content

feat(analytics): app-scoped analytics read endpoint (2/3) - #2192

Open
soamdesai-tfh wants to merge 11 commits into
feat/world-id-analytics-datafrom
feat/world-id-analytics-read
Open

feat(analytics): app-scoped analytics read endpoint (2/3)#2192
soamdesai-tfh wants to merge 11 commits into
feat/world-id-analytics-datafrom
feat/world-id-analytics-read

Conversation

@soamdesai-tfh

@soamdesai-tfh soamdesai-tfh commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Second of three (on #2191). The one authenticated read path for all analytics surfaces.

  • GET /api/portal/apps/{app_id}/world-id-analytics?environment&period[&action_ids]
  • DB-backed authz via getIsUserAllowedToReadApp (404, no existence leak) + soft-delete 404; missing/cross-app/cross-environment/wrong-source ids reject 400 before any read
  • Combined v3+v4 app series computed in PostgreSQL; UTC zero-fill; All Time starts at app creation (v3) or RP registration (v4-only); bigint-safe integer-string counts
  • Lands the fresh-stack integration suite + opt-in million-row gate

Tests: endpoint unit 26/26, integration 18/18; million gate — 1M rows: backfill via one dated POST 372ms, cron tick 31ms, endpoint p95 <8ms, plans never touch the raw nullifier tables.

Deploy: see #2191.

@soamdesai-tfh
soamdesai-tfh force-pushed the feat/world-id-analytics-data branch from 2d9c3d9 to 093f412 Compare July 31, 2026 07:41
@soamdesai-tfh
soamdesai-tfh force-pushed the feat/world-id-analytics-read branch from 7b12100 to 705315e Compare July 31, 2026 07:41
@soamdesai-tfh
soamdesai-tfh force-pushed the feat/world-id-analytics-read branch from 705315e to 268ecfc Compare July 31, 2026 14:31
@soamdesai-tfh
soamdesai-tfh force-pushed the feat/world-id-analytics-read branch from 268ecfc to 3abc011 Compare July 31, 2026 16:46
@soamdesai-tfh
soamdesai-tfh force-pushed the feat/world-id-analytics-read branch from 3abc011 to e7030b9 Compare July 31, 2026 21:29
@soamdesai-tfh
soamdesai-tfh marked this pull request as ready for review August 3, 2026 00:49
soamdesai-tfh and others added 3 commits August 3, 2026 14:44
GET /api/portal/apps/{app_id}/world-id-analytics: database-backed app
authorization with soft-delete 404s, id resolution against both action
tables with ambiguity/cross-app/cross-environment/wrong-source rejection,
PostgreSQL-side combined app aggregation, UTC zero-filling with the
three All Time start branches, bigint-safe integer-string counts, and
source-specific legacy_actions/actions blocks. Lands the fresh-stack
integration suite and the opt-in million-row load gate, which exercise
the data layer and this endpoint together.
The data slice scoped the fresh-stack runner to its own suites; now
that integration.test.ts and million.test.ts exist in this tree,
re-extend the default path and restore the --million entrypoint and
its package script.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Follows up 2191's action_v3_stats_daily -> action_legacy_stats_daily
rename: the field name and alias in get-world-id-analytics.graphql,
the endpoint's literal refs and hasV3History/has_v3_history naming,
and every test call site (integration.test.ts, million.test.ts,
world-id-analytics.test.ts). Regenerated the operation's generated.ts.

Also fixes a real bug the rename exposed: integration.test.ts's
tracked-table discovery regex hardcoded action_v[34]_stats_daily,
so it silently stopped matching the renamed table. Broadened to
action_(?:legacy|v4)_stats_daily.

Verified: tsc, prettier, unit 26/26, fresh-stack smoke+backfill+
integration 29/29, million gate 1/1 (1M-row backfill+catchup+parity).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@soamdesai-tfh
soamdesai-tfh force-pushed the feat/world-id-analytics-read branch from fee4fd4 to 6c3f84d Compare August 3, 2026 21:53
soamdesai-tfh and others added 2 commits August 4, 2026 16:44
The cron route now reports distinct outcomes and advances at most 30
days per tick, so the integration assertions pin the exact outcome
(advanced vs lock_missed) instead of a bare success body, and the
million gate's initial 31-day backfill follows the production runbook
through backfill_world_id_analytics(1) while the catch-up tick keeps
exercising the capped route.

Evidence on this tree: fresh-stack default runner green (data-slice
suites + integration 19/19), million gate green - 1M-row chunked
backfill 506ms, catch-up 42ms, endpoint p95 ~29ms/24ms both periods.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… stateless rollup

Historical seeds now build through dated route POSTs (the production
backfill path) instead of the deleted watermark bootstrap and procedure.
The lock-miss tests become queueing tests — a concurrent cron invocation
blocks behind the running one and both advance with nothing lost or
doubled. The stalled-watermark recovery test becomes the dated repair
call it is in production; the deletion race now lands in failed_ranges
(the retry input) instead of a 500. The million gate drives the 31-day
1M-row backfill through one dated POST (4 chunks) and proves the cron
tick recaptures late rows inside the trailing window; state-table
assertions are gone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
soamdesai-tfh and others added 2 commits August 5, 2026 22:32
… failing it

Merge-forward of the parent-lock fix: with the rollup pre-locking its
parent actions, a mid-chunk deletion queues on the parent (previously it
deadlocked as the 40P01 victim, and this test's old choreography let it
slip through only because a first-ever rollup locks no child rows). The
chunk now completes, the deletion cascades after, and a re-roll of the
range stays empty.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant